import React, {useRef } from "react";
function Ref() {
  const inputEl = useRef(null);
  function btnClick(){
    inputEl.current.focus();
    console.log("值：",inputEl.current.value)
  }
  return (
    <div>
      <input ref={inputEl} type="text"/>
      <button onClick={btnClick}>Focus the input</button>
    </div>
  );
}
export default Ref;
